import { Application } from "egg";
import { hc } from "../hc";
import HcWanCMDAudioService from "./cmd/audio";
import HcWanCmdParamsService from "./cmd/params";
import HcWanCmdPersonService from "./cmd/person";
import HcWanCmdRecordService from "./cmd/record";
import MachineToolsWanService from "./cmd/tools";

const symbolAudioInstance = Symbol("#audioInstance");
const symbolParamsInstance = Symbol("#paramsInstance");
const symbolPersonInstance = Symbol("#personInstance");
const symbolRecordInstance = Symbol("#recordInstance");
const symbolToolsInstance = Symbol("#toolsInstance");

export default class HCWanService {
	constructor(protected device: hc.http.device, protected app: Application) {}

	get audio() {
		if (!this[symbolAudioInstance]) {
			this[symbolAudioInstance] = new HcWanCMDAudioService(this.device, this.app);
		}
		return this[symbolAudioInstance] as HcWanCMDAudioService;
	}
	get params() {
		if (!this[symbolParamsInstance]) {
			this[symbolParamsInstance] = new HcWanCmdParamsService(this.device, this.app);
		}
		return this[symbolParamsInstance] as HcWanCmdParamsService;
	}
	get person() {
		if (!this[symbolPersonInstance]) {
			this[symbolPersonInstance] = new HcWanCmdPersonService(this.device, this.app);
		}
		return this[symbolPersonInstance] as HcWanCmdPersonService;
	}
	get record() {
		if (!this[symbolRecordInstance]) {
			this[symbolRecordInstance] = new HcWanCmdRecordService(this.device, this.app);
		}
		return this[symbolRecordInstance] as HcWanCmdRecordService;
	}
	get tools() {
		if (!this[symbolToolsInstance]) {
			this[symbolToolsInstance] = new MachineToolsWanService(this.device, this.app);
		}
		return this[symbolToolsInstance] as MachineToolsWanService;
	}
}
